package salary

type PaydayTransaction struct {
	Date string
	Map  map[int]Paycheck
}

func GetPaydayTransaction(date string) *PaydayTransaction {
	return &PaydayTransaction{Date: date, Map: make(map[int]Paycheck, 10)}
}

func (p *PaydayTransaction) Execute() {
	all := GetDB().GetAll()
	for _, employee := range all {
		if employee.PaymentSchedule.IsPayDay(p.Date) {
			paycheck := Paycheck{
				PayStartTime: employee.PaymentSchedule.GetStartPayDate(p.Date).String(),
				PayDate:      p.Date,
			}
			employee.PayDay(paycheck)
			p.Map[employee.EmployeeId] = paycheck
		}
	}
}
